home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
metkit
/
setup.exe
/
EXAMPLES
/
KBIND
/
KBOUND.H
< prev
next >
Wrap
C/C++ Source or Header
|
1997-06-08
|
4KB
|
83 lines
// Copyright (C) 1996, 1997 Meta Four Software. All rights reserved.
//
// KitBinder embedded data support, public interface
//
//! rev="$Id: kbound.h,v 1.4 1997/05/27 10:42:39 jcw Rel $"
/////////////////////////////////////////////////////////////////////////////
//
// Embedding a MetaKit datafile inside an executable file.
//
// The c4_BoundStorage class can be used to access read-only data which
// has been stored as part of an executable file. In a way, this makes
// MetaKit suitable as a form of platform-independent resource manager,
// with all the data structures and manipulation of MetaKit thrown in.
//
// All stored data is also compressed using a simple, very fast variation
// of Lempel-Zev compression (by Ross N. Williams), and can optionally be
// encoded using a custom function (defined by c4_BoundStorage::_Encoder).
//
// To use this embedding, you need to have a regular MetaKit datafile and
// "bind" it to the executable. On Windows, data is stored in resources.
// Only Win 16/32 is currently supported, Macintosh support should be very
// easy to add, other platforms may need more work (to simulate resources).
//
// A tiny command-line utility called "KitBinder" is used to generate files
// which can then be linked into the application by the resource linker.
// KitBinder has to be run each time you want to alter the bound data.
//
// The process of switching to bound data is quite simple:
//
// 1. Presumably, you have a MetaKit datafile with some data in it.
// Let's assume it is now stored in a file called "try.dat".
// 2. Create source files for the resource editor (if on Win 32):
// kbinder try.dat kbtry
// Or, for Win16, use a text format instead:
// kbinder -t try.dat kbtry
// 3. This produces a file called "kbtry.rc", as well as one or more
// files called "kbtryXXX.res" (or "kbtryXXX.rc" if text format).
// 4. Add the following line to your application resource file:
// #include "kbtry.rc"
// 5. Include the file "kbound.h" to define the c4_BoundStorage class,
// and include the code which is in "kbound.cpp" in your project.
// 6. Create your storage object from the class "c4_BoundStorage",
// instead of "c4_Storage", and omit parameters, ie. change this:
// c4_Storage myStorage ("try.dat", false);
// to:
// c4_BoundStorage myStorage;
// 7. That's it, you now have a read-only copy of "try.dat" bound to
// your application and no longer need that data file at run time.
// Everything will continue to work, but you cannot commit changes.
// You can however call DumpAsRes, or c4_Storage::SaveToStream.
//
// For the original comments about the compression code, see "kboundw.cpp".
//
// To use encoding, you need to point c4_BoundStorage::_Encoder to an
// appropriate function before creating any instances of c4_BoundStorage.
//
/////////////////////////////////////////////////////////////////////////////
#ifndef __KBOUND_H__
#define __KBOUND_H__
#include <m4kit.h>
class c4_BoundStorage : public c4_Storage
{
public:
enum { kBlockSize = 10000 };
c4_BoundStorage (int base_ =100);
~c4_BoundStorage ();
static int DumpAsRes(c4_Storage& orig_, const char* prefix_,
bool asText_ =false, int base_ =100);
// this can be set to a function which implements encoding/decoding
static void (*_Encoder)(bool,int,char*,int);
};
/////////////////////////////////////////////////////////////////////////////
#endif